﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Data;
using System.Collections;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;

namespace KPIS.GERP.GHRMS.APP.App_UI.Controls
{
    public partial class DistrictCombo : System.Web.UI.UserControl
    {
        private IMasDistrictBLL BLL = new MasDistrictBLL();
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public void ListDistrictComboBox()
        {
            ListDistrictComboBox("");
        }
        public void ListDistrictComboBox(string Province)
        {
            IList<MasDistrictInfo> InfoList = BLL.ListDistricts("", "", Province);

            foreach (MasDistrictInfo List in InfoList)
            {
                RadComboBoxItem item = new RadComboBoxItem();

                item.Text = List.Name;
                item.Value = List.Sequence.ToString();

                item.Attributes.Add("District", List.Name);
                item.Attributes.Add("Amphurs", List.Amphurs.Name);
                item.Attributes.Add("Provinces", List.Amphurs.Provinces.Name);

                cbDistrict.Items.Add(item);
                item.DataBind();
            }
        }
        //protected void cbDistrict_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        //{
        //     IList<MasDistrictInfo> InfoList = BLL.ListDistricts();

        //    foreach (MasDistrictInfo List in InfoList)
        //    {
        //        RadComboBoxItem item = new RadComboBoxItem();

        //        item.Text = List.Name;
        //        item.Value = List.Sequence.ToString();

        //        item.Attributes.Add("District", List.Name);
        //        item.Attributes.Add("Amphurs", List.Amphurs.Name);
        //        item.Attributes.Add("Provinces", List.Amphurs.Provinces.Name);

        //        cbDistrict.Items.Add(item);
        //        item.DataBind();
        //    }
        //    //cbDistrict.DataSource = InfoList;
        //    //cbDistrict.DataBind();


        //    //int itemOffset = e.NumberOfItems;
        //    //int endOffset = Math.Min(itemOffset + 10, InfoList.Count);
        //    //e.EndOfItems = endOffset == InfoList.Count;

        //    //for (int i = itemOffset; i < endOffset; i++)
        //    //{
        //    //    cbDistrict.Items.Add(new RadComboBoxItem(InfoList[i].Name, InfoList[i].Sequence.ToString()));
        //    //}

        //    //e.Message = GetStatusMessage(endOffset, InfoList.Count);
        //}
        //private static string GetStatusMessage(int offset, int total)
        //{
        //    if (total <= 0)
        //        return "No matches";

        //    return String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", offset, total);
        //}
    }
}